<include file="public/head" />
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
	<div class="ibox float-e-margins">
		<div class="ibox-title">
			<h5>权限资源列表(共{$right_list|count}条记录)</h5>
			<div class="ibox-tools" style="margin-top: -9px;">
				<a href="javascript:location.reload();" class="btn btn-primary"><i class="fa fa-refresh"></i> 刷新</a>
			</div>
		</div>
		<div class="ibox-content">
			<div class="row row-lg">
				<div class="col-sm-12">
					<a class="btn btn-primary" href="{:url('admin/edit_right')}">添加权限</a>
					<br/>
					<div class="row">
						<div class="col-sm-3 pull-right">
							<div class="input-group">
								<input type="text" placeholder="请输入关键词" class="input-sm form-control"> <span class="input-group-btn">
								<button type="button" class="btn btn-sm btn-primary"> 搜索</button> </span>
							</div>
						</div>
					</div>

					<div class="table-responsive">
						<!--class="table table-bordered table-hover"-->
						<table data-toggle="table" class="table table-bordered table-hover"
						>
							<thead>
								<tr  style="background: #f9f9f9;">
									<th>名称</th>
									<th>资源类型</th>
									<th>所属分组</th>
									<th>权限码</th>
									<th>操作</th>
								</tr>
							</thead>
							<tbody>
							<volist name="right_list" id="vo">
								<tr>
									<td><div class="cut_title ellipsis">{$vo['id']}</div></td>
									<td>{$vo.name}</td>
									<td>{$group[$vo['group']]}</td>
									<td>{$vo.right}</td>
									<td>
										<a href="{:url('admin/edit_right',array('id'=>$vo['id']))}" class="btn btn-primary">编辑</a>
										<a  href="javascript:;" data-id="{$vo.id}"  class="btn btn-danger btn-del" >删除</a>
									</td>
								</tr>
							</volist>
							</tbody>
						</table>
					</div>
					<div class="col-sm-12">
						<!-- Example Pagination -->
						<ul class="pagination  pull-right">
							{$page}
						</ul>
						<!-- End Example Pagination -->
					</div>
				</div>
			</div>
			<!-- End Panel Basic -->
		</div>

		<!-- 全局js -->
		<script src="__STATIC__/admin/js/jquery.min.js?v=2.1.4"></script>
<script>
	$(document).ready(function(){
		// 表格行点击选中切换
		$('#flexigrid > table>tbody >tr').click(function(){
			$(this).toggleClass('trSelected');
		});

		// 点击刷新数据
		$('.fa-refresh').click(function(){
			location.href = location.href;
		});

	});


	$(".btn-del").click(function(){
		var id = $(this).attr('data-id');
		alert(id);
		parent.layer.confirm('删除数据无法恢复，并且会影响用户数据，确定删除？', {
			shade:false,
			btn: ['确定', '取消']
		}, function() {
			$.post("{:url('admin/right_del')}", {id: id}, function (result) {
				if (result.code == '0') {
					parent.layer.alert(result.msg);
				} else {
					parent.layer.msg(result.msg, {
								icon:1
							},
							function (index, item) {
//								parent.layer.close(index);
								location.reload();
							});
				}
			});
		});
	})
</script>
</body>
</html>